package com.h2View.entity;

import com.h2View.exception.ServiceException;
import com.h2View.utils.MsgType;

import lombok.Data;

/**
 * @author xwx1052336
 * @since iFad Platform V100R001,2021/9/10
 */
@Data
public class MsgBox {

    private MsgType msgType;
    private String msg;
    private String sendUrl;
    private String reciveUrl;
    private Runnable runnable;
    private Object data;
    private Thread thread;
    private Object lock = new Object();

    public void setRunnable(Runnable runnable){
        this.runnable = runnable;
        thread = new Thread(runnable);
    }

    public void start(){
        if(thread == null){
            throw new ServiceException("thread is not init");
        }
        thread.start();
    }

    public MsgBox(MsgType msgType){
        this.msgType = msgType;
    }

    public MsgBox(){
        this(MsgType.INFOMSG);
    }

}
